package object;

public class Student extends Person {
    private Course course;

    public Student(String id, String name, String gender) {
        super(id, name, gender);
    }

    public void selectCourse(Course course) {
        this.course = course;
    }

    public void dropCourse() {
        this.course = null;
    }

    @Override
    public void printWorkSheet() {
        super.printWorkSheet();
        if (course != null) {
            System.out.println("学生课表：" + course);
        } else {
            System.out.println("学生课表：未选任何课程");
        }
    }

    @Override
    public String toString() {
        return "学生[编号:" + id + "，姓名:" + name + "，性别:" + gender + "，所选课程:" + (course != null ? course.getName() : "无") + "]";
    }
}